<template>
	<view class="page">
		<u-navbar title="在线留言" :auto-back="true">
			<view class="u-nav-slot" slot="right">
				<view class="nav-right" @click="openPopUp">
					<u-icon name="search" size="24" color="#376CB4"></u-icon>
					<u-icon name="list" size="24" style="margin-left: 20rpx;" color="#376CB4"></u-icon>
				</view>
			</view>
		</u-navbar>
		<view class="ll"></view>

		<view class="bk-box">
			
			<view class="search-empty" v-if="rst.length <= 0">
				<image src="../../static/kong.png" class="empty-img"></image>
			</view>
			
			<view class="bk-box-item" v-for="(item, index) in rst" :key="index">
				<view class="bk-box-item-title"> 
					<view class="font-28 bkbk-title" style="margin-left: 10rpx;">标题:{{item.contact}}</view>
				</view>
				<view class="bk-box-item-content font-24">
					 内容：{{item.content}}
				</view>
				<view class="bk-box-item-content font-24">
					 回复：{{item.reply}}
				</view>
			</view>
		</view>
		<CommonTk  ref="commonTk"></CommonTk>
		<view class="msg-btn" @click="addLevelMsg">+添加留言</view>
	</view>
</template>

<script>
	import CommonTk from '@/components/CommonTk.vue'
	import Footer from '@/components/Footer.vue'
	import {
		api,
		apiBaseUrl,
		http
	} from '@/config/common.js'
	export default {
		data() {
			return {
				page: 1,
				total_page: 1,
				rst: []
			}
		},
		components: {
			Footer,
			CommonTk
		},
		filters: {},
		mounted() {},
		onLoad(e) {
			this.getQkDt()
		},
		onShow() {},
		beforeDestroy() {},
		onPageScroll(e) {},
		onReachBottom() {
			if (this.page < this.total_page) {
				this.page = this.page + 1
				this.getQkDt()
			} else {
				console.log('no more')
			}
		},
		methods: {
			openPopUp() {
				this.$refs.commonTk.openShow()
			},
			getQkDt() {
				api.post('api/index/level_msg_list', { 
					page: this.page,
					pageSize: 15
				}).then(res => {
					let rst = res.data
					if (rst.code == 1) {
						let result = rst.data
						this.total_page = result.last_page
						let temp_rst = result.data;
						this.rst = this.rst.concat(temp_rst)
					}
				}).catch(err => {})
			}, 
			addLevelMsg(){
				uni.navigateTo({
					url:'/pages/other/add_leave_message'
				})
			}
		}
	};
</script>

<style scoped>
	.msg-btn{
		width: 750rpx;
		height: 88rpx;
		background: #376DB5;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #FFFFFF;
		position: fixed;
		bottom: 0;
	}
	.bkbk-title {
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		overflow: hidden;
		width: 100%;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;
	}

	.bk-box-item-content { 
		/* line-height: 40rpx; */
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
		margin-top: 10rpx;
	}

	.bk-box-item {
		padding: 30rpx 0;
		border-bottom: 2rpx solid #E5E5E5;
	}

	.bk-box-item-title {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-bottom: 20rpx;

	}

	.bk-box-item-title-img {
		width: 32rpx;
		height: 28rpx;
	}

	.bk-box {
		width: 690rpx;
		margin: 0 auto;
	}

	.ll {
		height: 90rpx;
	}

	::v-deep .u-navbar__content {
		width: 750rpx;
		height: 88rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 2rpx 14rpx 0rpx rgba(4, 0, 0, 0.14);
	}

	.nav-right {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.logo {
		width: 306rpx !important;
		height: 55rpx !important;
	}

	page {
		background-color: #fff;
		padding-bottom: 90rpx;
	}
</style>